package com.whc.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.system.common.pojo.BisBusinessOrder;
import com.whc.service.BisBusinessOrderService;


@Controller
@RequestMapping("bus")
public class BusinessOrderController {
	
	@Autowired
	private BisBusinessOrderService orderService;
	
	@RequestMapping("list")
	public String list(Model model,HttpServletRequest request){
		Map<String, Object> map=mmxx(request);
		List<BisBusinessOrder> list=this.orderService.selectAll(map);
		model.addAttribute("list",list);		
		model.addAttribute("shops", orderService.listAllShop());		
		return "business.whc/businessOrderList";
	}
	
	
	public Map<String, Object> mmxx(HttpServletRequest request){
		Map<String, Object> map =new HashMap<>();
		String orderId = request.getParameter("orderId");//定义变量
		String phone=request.getParameter("phone");
		String shopname=request.getParameter("shopname");
		String payWay=request.getParameter("payWay");
		String orderStatus=request.getParameter("orderStatus");
		String orderSource=request.getParameter("orderSource");
		String shopName=request.getParameter("shopName");
		String username=request.getParameter("username");
		String shopusername=request.getParameter("shopusername");
		String project=request.getParameter("project");
		
		if (project!=null) {
			map.put("project", project);//消费内容
		}
		if (orderId!=null) {
			map.put("orderId", orderId);//订单编号
		}
		if (phone!=null) {
			map.put("phone",phone);//顾客账号
		}
		if (shopname!=null) {
			map.put("shopname", shopname);//顾客姓名
		}
		if (payWay!=null) {
			map.put("payWay", payWay);//支付方式
		}
		if (orderStatus!=null) {
			map.put("orderStatus", orderStatus);//订单状态
		}
		if (orderSource!=null) {
			map.put("orderSource", orderSource);//订单来源
		}
		if (shopName!=null) {
			map.put("shopName", shopName);//店铺名称
		}
		if (username!=null) {
			map.put("username", username);//服务员工
		}
		if (shopusername!=null) {
			map.put("shopusername", shopusername);//最后操作员工
		}
		String qstartTime = request.getParameter("qstartTime");
		if(StringUtils.isNotBlank(qstartTime)){//完成日期
			map.put("qstartTime", qstartTime);
		}
		String qendTime = request.getParameter("qendTime");
		if(StringUtils.isNotBlank(qendTime)){//完成日期
			map.put("qendTime", qendTime);
		}
		
		System.out.println(qstartTime+":"+qendTime);
		
		return map;
	}

}
